package cc.co.cutenimy.nimyexplore.rcp.views;

import cc.co.cutenimy.nimyexplore.model.jdbc.ConnectionInstance;

/**
 * 
 * @author 234aini@gmail.com
 *
 * @param <T>
 */
public abstract class DoubleClickEventHandler<T> {
	public abstract void handle(T t);

	public final static DoubleClickEventHandler<Object> DUMMY_HANDLER = new DoubleClickEventHandler<Object>() {
		@Override
		public void handle(Object obj) {
		}
	};

	@SuppressWarnings("unchecked")
	public static <T> DoubleClickEventHandler<T> getHandler(final T t) {
		if (t instanceof ConnectionInstance) {
			return (DoubleClickEventHandler<T>) new DoubleClickEventHandler<ConnectionInstance>() {
				@Override
				public void handle(ConnectionInstance t) {
					// Edit the connection instance details.
				}
			};
		}
		return (DoubleClickEventHandler<T>) DUMMY_HANDLER;
	}
}
